import routers from './router';
import FieldListView from './components/FieldListView.vue';

import PaymentRecord from './view/committee/components/paymentRecord.vue';
import DownloadLink from './view/committee/components/downloadLink.vue';
import CommitteeWorkgroup from './view/committee/components/workgroup.vue';
import UploadBtn from './view/committee/components/uploadBtn.vue';

export default {
  config: {
    dependencies: ['standards'],
    beDenpendencies: ['portal'],
  },
  routers,
  fieldComponents: {
    FieldListView,
    PaymentRecord,
    DownloadLink,
    CommitteeWorkgroup,
    UploadBtn,
  },
  filters: {
    yesOrNo: (d) => (d ? '是' : '否'),
    RMB: (d) => {
      if (!d) return '0.00元';

      const numVal = Number(d);

      // 如果金额小于10万，直接返回
      if (numVal < 100000) {
        return `${numVal.toFixed(2)}元`;
      }

      // 如果金额大于10万，返回以万为单位的金额
      if (numVal) {
        return `${(numVal / 10000.0).toFixed(2)}万元`;
      }

      return `${numVal}元`;
    },
  },
  validators: {
    // password
    validatorPwd: (d) => /^.*(?=.{10,16})(?=.*\d)(?=.*[A-Za-z])(?=.*[!@#$%^&*?()]).*$/.test(d),
  },
};
